package com.atguigu.ssyx.client.cart;

import com.atguigu.ssyx.common.result.Result;
import com.atguigu.ssyx.model.order.CartInfo;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;


@FeignClient(value = "service-cart")
public interface CartFeignClient {
    /**
     * 添加购物车
     *
     * @param skuId
     * @param skuNum
     * @return
     */
    @GetMapping("/api/cart/addToCart/{skuId}/{skuNum}")
    Result addToCart(@PathVariable("skuId") Long skuId, @PathVariable("skuNum") Integer skuNum);

    /**
     * 删除购物车某个商品
     *
     * @param skuId
     * @param request
     * @return
     */
    @DeleteMapping("/api/cart/deleteCart/{skuId}")
    Result deleteCart(@PathVariable("skuId") Long skuId,
                      HttpServletRequest request);

    @ApiOperation(value = "清空购物车")
    @DeleteMapping("/api/cart/deleteAllCart")
    Result deleteAllCart(HttpServletRequest request);

    @ApiOperation(value = "批量删除购物车")
    @PostMapping("/api/cart/batchDeleteCart")
    Result batchDeleteCart(@RequestBody List<Long> skuIdList);

    /**
     * 查询购物车列表
     *
     * @param
     * @return
     */
    @GetMapping("/api/cart/cartList")
    Result cartList();

    /**
     * 根据用户Id 查询购物车列表
     *
     * @param userId
     */
    @GetMapping("/api/cart/inner/getCartCheckedList/{userId}")
    List<CartInfo> getCartCheckedList(@PathVariable("userId") Long userId);

    /**
     * 查询参与活动且带优惠卷的购物车
     *
     * @param
     * @return
     */
    @GetMapping("/api/cart/activityCartList")
    public Result activityCartList();

    /**
     * 更新选中状态
     *
     * @param skuId
     * @param isChecked
     * @param
     * @return
     */
    @GetMapping("/api/cart/checkCart/{skuId}/{isChecked}")
    Result checkCart(@PathVariable(value = "skuId") Long skuId,
                     @PathVariable(value = "isChecked") Integer isChecked);

    /**
     * 全选或全不选
     */
    @GetMapping("/api/cart/checkAllCart/{isChecked}")
    Result checkAllCart(@PathVariable(value = "isChecked") Integer isChecked);

    @ApiOperation(value = "批量选择购物车")
    @PostMapping("/api/cart/batchCheckCart/{isChecked}")
    Result batchCheckCart(@RequestBody List<Long> skuIdList, @PathVariable(value = "isChecked") Integer isChecked);
}